package com.company;

import java.util.Scanner;

public class Demo13 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入数列的个数");
        int n=scanner.nextInt();
        int []a=new int[n];
        System.out.println("请输入数列");
        a[0]= scanner.nextInt();

        for (int i = 1; i < n; i++) {
            a[i]= a[i-1]+scanner.nextInt();
        }
        System.out.println("请输入要求的数列区间");
        int b= scanner.nextInt();
        int c= scanner.nextInt();
        if (b == 1) {
            System.out.println("区间和是："+a[c-1]);

        }
        else {
            int aa=a[c-1]-a[b-2];
            System.out.println("区间和是："+aa);}


    }
}
